<template>
	<view>
		<map id="myMap"  subkey="WKHBZ-V5ZCU-7ODVC-BGXDB-HNV7J-KQBMP" layer-style="1" :markers="markers" style="width:100%;height:100vh;" :longitude="longitude" :latitude="latitude" scale='16'>
		</map>
	</view>
</template>

<script>
	// 导游 33.404659 115.089099
	// 平安 33.403977 115.088245
	// 一号 33.404098 115.087183
	export default {
		data() {
			return {
				markers: [],
				latitude: 33.404659,
				longitude: 115.089099
			}
		},
		onLoad() {
			//latitude: 34.12596, longitude: 113.82272
			//定位地址
			uni.getLocation({
				success: data => {
					console.log(data)
					this.longitude=data.longitude
					this.latitude=data.latitude
					this.initData()
					this.markers.push({
						title: "自己(目前为止)",
						id: 1,
						width:35,
						height:35,
						latitude: data.latitude,
						longitude: data.longitude,
						label:{content:"自己(目前位置)",color:"#1aad19"},
						iconPath: "../../../../../static/mainPeo.png"
					})
				}
			})
			
		},
		methods: {
			initData(){
				//生成随机
				let longitude=Number(this.longitude).toFixed(2),latitude=Number(this.latitude).toFixed(2)
				console.log(latitude,longitude)
				for(let i=0;i<3;i++){
					this.markers.push({
						title: "回收员",
						id: i+10,
						latitude: Number(latitude)+Math.random()/50,
						longitude: Number(longitude)+Math.random()/50,
						label:{content:"回收员",color:"#1aad19"},
						width:30,
						height:30,
						callout: {
							content: "回收员",
							borderColor: 'blue'
						},
						iconPath: "../../../../../static/somePeo.png"
					})
				}
				for(let i=0;i<3;i++){
					this.markers.push({
						title: "回收员",
						id: i+20,
						latitude: Number(latitude)-Math.random()/10,
						longitude: Number(longitude)-Math.random()/10,
						label:{content:"回收员",color:"#1aad19"},
						width:30,
						height:30,
						callout: {
							content: "回收员",
							borderColor: 'blue'
						},
						iconPath: "../../../../../static/somePeo.png"
					})
				}
				for(let i=0;i<3;i++){
					this.markers.push({
						title: "回收员",
						id: i+20,
						latitude: Number(latitude)+Math.random()/10,
						longitude: Number(longitude)-Math.random()/10,
						label:{content:"回收员",color:"#1aad19"},
						width:30,
						height:30,
						callout: {
							content: "回收员",
							borderColor: 'blue'
						},
						iconPath: "../../../../../static/somePeo.png"
					})
				}
				for(let i=0;i<3;i++){
					this.markers.push({
						title: "回收员",
						id: i+20,
						latitude: Number(latitude)-Math.random()/10,
						longitude: Number(longitude)+Math.random()/10,
						label:{content:"回收员",color:"#1aad19"},
						width:30,
						height:30,
						callout: {
							content: "回收员",
							borderColor: 'blue'
						},
						iconPath: "../../../../../static/somePeo.png"
					})
				}
			}
		}
	}
</script>

<style>

</style>
